#ifndef H_EEPROM
#define H_EEPROM

#include "Arduino.h"

#define MAXEEPROMADDR 1023 // 1kb of eeprom on 328p

class Disk
{
public:
  void blockRead(int address, byte *buf,int len)
  {
    int i;
    for(i=0;i<len;i++)
      buf[i]=EEPROM.read(address+i);
  }

  void blockWrite(int address, byte *buf,int len)
  {
    int i;
    for(i=0;i<len;i++)
      EEPROM.write(address+i,buf[i]);
  }
  
  // FLOAT *****************************************
  void writeFloat(int address,float val)
  {
    for(int i=0;i<4;i++)
      EEPROM.write(address+i,((byte*)&val)[i]);
  }
  float readFloat(int address)
  {
    float val;

    for(int i=0;i<4;i++)
      ((byte*)&val)[i]=EEPROM.read(address+i);

    return val;
  }

  // BYTE *****************************************
  byte write(int address,byte val)
  {
    EEPROM.write(address,val);
  }
  byte read(int address)
  {  
    EEPROM.read(address);
  }



} disk;

#endif










